package com.yijiupi.plugin.test.toolwindow;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.EditorKind;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.ui.EditorTextField;
import com.intellij.uiDesigner.core.GridConstraints;
import com.yijiupi.plugin.test.progress.impl.ProgressTestServiceImpl;
import com.yijiupi.plugin.test.service.TestMoudle;
import org.apache.batik.dom.util.DocumentFactory;

import javax.swing.*;
import java.awt.*;

public class SqlToolsWindow {

    JPanel jPanel;
    private JButton parsingBtn;
    private JLabel updataTime;
    private JPanel editorPanel;

    Editor editor;

    private final static FileType FILE_TYPE = FileTypeManager.getInstance().getFileTypeByExtension("sql");
    /**
     * 编辑框大小样式配置
     */
    private final static GridConstraints GRID_CONSTRAINTS = new GridConstraints(0, 0, 1, 1,
            GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED,
            null, new Dimension(200, 1200), null,
            0, true);



    public SqlToolsWindow() {

    }

    public SqlToolsWindow(Project project) {
        EditorFactory editorFactory=EditorFactory.getInstance();
        Document document=editorFactory.createDocument("select * from sdgsdg where sdg='sdg");
        editor=editorFactory.createEditor(document,project,FILE_TYPE,true);
        ServiceManager.getService(TestMoudle.class).setEditor(editor);
        editorPanel.add(editor.getComponent(),GRID_CONSTRAINTS);
    }

    public JPanel getjPanel() {
        return jPanel;
    }

}
